#include "ContactItem.h"

ContactItem::ContactItem(const Contact &contact, QWidget *parent)
    : QWidget(parent), m_avatarLabel(new QLabel(this)), m_nameLabel(new QLabel(this))
{
    m_contactId = contact.id();
    m_avatarLabel->setPixmap(contact.avatar().scaled(48, 48, Qt::KeepAspectRatio, Qt::SmoothTransformation));
    m_nameLabel->setText(contact.name());

    m_layout = new QHBoxLayout(this);
    m_layout->setContentsMargins(0, 1, 0, 1);
    m_layout->addWidget(m_avatarLabel);
    m_layout->addWidget(m_nameLabel);
    setLayout(m_layout);
}

ContactItem::~ContactItem()
{
    m_avatarLabel->deleteLater();
    m_nameLabel->deleteLater();
    m_layout->deleteLater();
}

int ContactItem::getContactId()
{
    return m_contactId;
}
